import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 设备信息信息 */
export interface Device {
          id: number; // 设备ID
          remark: string; // 备注
  }

/** 批量修改分组请求参数 */
export interface UpdateGroupReq {
  ids: number[]; // 设备ID列表
  groupId?: number; // 分组ID
}

// 设备信息 API
export const DeviceApi = {
  // 查询设备信息分页
  getDevicePage: async (params: any) => {
    return await request.get({ url: `/yunkong/device/page`, params })
  },

  // 查询设备信息详情
  getDevice: async (id: number) => {
    return await request.get({ url: `/yunkong/device/get?id=` + id })
  },

  // 获取分组下的设备列表
  getDeviceListByGroupId: async (groupId: number) => {
    return await request.get({ url: `/yunkong/device/list-by-group?groupId=${groupId}` })
  },

  // 新增设备信息
  createDevice: async (data: Device) => {
    return await request.post({ url: `/yunkong/device/create`, data })
  },

  // 修改设备信息
  updateDevice: async (data: Device) => {
    return await request.put({ url: `/yunkong/device/update`, data })
  },

  // 删除设备信息
  deleteDevice: async (id: number) => {
    return await request.delete({ url: `/yunkong/device/delete?id=` + id })
  },

  /** 批量删除设备信息 */
  deleteDeviceList: async (ids: number[]) => {
    return await request.delete({ url: `/yunkong/device/delete-list?ids=${ids.join(',')}` })
  },

  /** 批量修改设备分组 */
  updateDeviceGroup: async (data: UpdateGroupReq) => {
    return await request.put({ url: `/yunkong/device/update-group`, data })
  },

  // 导出设备信息 Excel
  exportDevice: async (params) => {
    return await request.download({ url: `/yunkong/device/export-excel`, params })
  }
}